<?php
    $is_expired          = osc_item_is_expired () ;
    $is_user             = !( ( osc_logged_user_id() == osc_item_user_id() ) && osc_logged_user_id() != 0 ) ;
    $is_can_contact      = osc_reg_user_can_contact() && osc_is_web_user_logged_in() || !osc_reg_user_can_contact() ;
    
    $is_comments_enabled = osc_comments_enabled() ;
    $is_can_comment      = osc_reg_user_post_comments () && osc_is_web_user_logged_in() || !osc_reg_user_post_comments() ;
?>
<!DOCTYPE html>
<html dir="ltr" lang="<?php echo str_replace('_', '-', osc_current_user_locale()); ?>">
    <head>
        <?php osc_current_web_theme_path('head.php') ; ?>
        <script type="text/javascript" src="<?php echo osc_current_web_theme_js_url('fancybox/jquery.fancybox-1.3.4.js') ; ?>"></script>
        <script type="text/javascript" src="<?php echo osc_current_web_theme_js_url('bootstrap-modal.js') ; ?>"></script>
        <link href="<?php echo osc_current_web_theme_js_url('fancybox/jquery.fancybox-1.3.4.css') ; ?>" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
            $(document).ready(function(){
                $("a[rel=image_group]").fancybox();

                $(".item-contact-button-cancel").bind('click', function(event) {
                    $('#item-contact').modal('hide') ;
                }) ;

                $('#item-contact .close').bind('click', function(event) {
                    $(this).modal('hide') ;
                }) ;
                
                $('#item-sendfriend .close').bind('click', function(event) {
                    $(this).modal('hide') ;
                }) ;

                $(".item-sendfriend-button-cancel").bind('click', function(event) {
                    $('#item-sendfriend').modal('hide') ;
                }) ;
            });
        </script>
        <?php if( osc_item_is_expired () ) { ?>
        <meta name="robots" content="noindex, nofollow" />
        <meta name="googlebot" content="noindex, nofollow" />
        <?php } else { ?>
        <meta name="robots" content="index, follow" />
        <meta name="googlebot" content="index, follow" />
        <?php } ?>
    </head>
    <body>
        <?php osc_current_web_theme_path('header.php') ; ?>
        
        <?php while ( osc_has_item_meta() ) { 	
         if(osc_item_meta_name() == "Phone" ) { 
              $m_phone = osc_field(osc_item_meta(), 's_value', '');	             
            } 
         if(osc_item_meta_name() == "Brand" ) { 
              $m_brand = osc_field(osc_item_meta(), 's_value', '');						
            } 
        } ?>
        
        <div class="container margin-top-10">
            <?php twitter_show_flash_message() ; ?>
        </div>
        <div class="container item-detail">
            <?php echo twitter_breadcrumb('&raquo;') ; ?>
            
            <div class="alert-success" style="padding-left: 10px;margin-bottom: 5px;">
                <table>
                <tr>
                    <td >
                        <span style="display:block;border-right: 1px solid #C8C8C8;height:25px;padding:0px 12px;">
                        <img src="<?php echo osc_current_web_theme_url('images/cat/black_'. osc_item_category_id() .'.png'); ?>" width="30" alt="<?php echo osc_category_slug(); ?>" />
                        </span>
                    </td>
                    <td>
                        <h1><?php echo osc_item_category() . " " . $m_brand . " " . __('used', 'twitter_bootstrap'); ?></h1>
                    </td>
                </tr>
                </table>
            </div>
            
            <div class="row">             
                <!-- item detail -->
                <div class="content_block">
				
				 <div id="item_head">
					
				</div>
				
				<div id="item_main" class="span9">
                                       <table style="width:100%;">
                                        <tr>
                                         <td>
                                            <h2 style="font-size:18px;"><?php echo osc_item_title(); ?></h2> 
                                         </td>
                                         <td style="float:right;">                                        
                                        <?php if( osc_price_enabled_at_items() ) { ?> 					
					<?php if (price_format(osc_item_formated_price()) != "") { ?>
                                            <span class="label info" style="float:right;font-size: 20px;background-color:#9CAF1E; padding: 6px 10px;text-transform: lowercase;">
                                                <?php echo price_format(osc_item_formated_price()) ; ?>
                                            </span>
                                         <?php } else { ?>
                                            <span style="float:right;font-size:12px;font-weight:bold;">
                                                <i class="icon-info-sign" title="<?php printf(__('Check price with seller', 'twitter_bootstrap')); ?>"></i>&nbsp;<?php echo price_format(osc_item_formated_price(),true) ; ?>
                                            </span>
                                         <?php } } ?>
					 </td>
                                        </tr>
                                       </table>
                                        <hr/>		
					<div style="display:inline-table;width:100%;margin-bottom:10px;">
					<span style="float:right;margin-left:10px;">
					<span class="label grey2" >
					<a href="<?php echo osc_item_category_url(osc_item_category_id()) ; ?>"><?php echo osc_item_category(); ?></a>
					</span>
					</span> 
										
					<div style="float:left;">
						<?php watchlist();?>
					</div>
					</div>
					<br/>
                   			<h2><strong><?php echo __('Features', 'twitter_bootstrap') . ": " . osc_item_title(); ?></strong></h2>		
					<?php osc_run_hook('item_detail', osc_item() ) ; ?>
					
					<?php if (osc_item_description() != "" && osc_item_description() != " ") { ?>
					<h2><strong><?php echo __('additional details', 'twitter_bootstrap'). ": " . osc_item_title(); ?></strong></h2>
					<hr/>
					<div class="alert alert-normal" style="padding:10px;">					
                                            <p><?php echo osc_item_description() ; ?></p>
                                        </div>
					<?php } ?>
                                        
                                        <div style="text-align:center;margin-top:10px;">
                                           <script type="text/javascript">
                                            google_ad_client = "ca-pub-1532681428717976";
                                            /* mercatrucks item2 */
                                            google_ad_slot = "9794600952";
                                            google_ad_width = 468;
                                            google_ad_height = 60;
                                            //
                                            </script>
                                            <script type="text/javascript"
                                            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                                            </script>
                                        </div>
					<hr/>
					<div>		
                                            <?php $item_location = item_detail_location() ; ?>
                                            <?php if( count($item_location) > 0 ) { ?>
                                            <p class="no-margin">
                                                <h4><?php printf(__('location', 'twitter_bootstrap')) ; ?></h4>
                                                <div style="float:right;"><strong><?php printf(implode(', ', $item_location)); ?></strong></div>
                                            </p>                   				
                                            <?php osc_run_hook('location') ; }?>
					</div>
                                        
					
					<!-- Dates -->
					<div id="dates" style="max-width:70%;float:left;margin-top:10px;">
					 <p class="no-margin"><?php printf(__('<strong>Published date:</strong> %s', 'twitter_bootstrap'), osc_format_date( osc_item_pub_date(), "d M Y, H:i" )) ; ?></p>
                    <?php if ( osc_item_mod_date() != '' ) { ?>
                    <p class="no-margin"><?php printf(__('<strong>Modified date:</strong> %s', 'twitter_bootstrap'), osc_format_date( osc_item_mod_date(), "d M Y, H:i" )) ; ?></p>
                    <?php } ?>
					</div>
					<!-- End dates -->
					
					<br/>
					
					<?php printf( social_bookmarks("")); ?>
					
                    <div style="float:right;max-width:30%;margin-top:12px;">
                        <?php if ( !$is_expired && $is_user && $is_can_contact ) { ?>
                        <!--<a class="btn primary item-contact-button" data-controls-modal="item-contact" data-backdrop="true" data-keyboard="true" href="javascript://"><?php //_e('Contact seller', 'twitter_bootstrap') ; ?></a>-->
                        <?php } ?>
                        <a class="btn item-share-button" data-controls-modal="item-sendfriend" data-backdrop="true" data-keyboard="true" href="javascript://"><?php _e('Send to a friend', 'twitter_bootstrap') ; ?></a>
                    </div>
		</div>
		<div id="sidebar" class="span6" style="float:right;">
					<!-- Photos -->
					<?php if( osc_images_enabled_at_items() && (osc_count_item_resources() > 0) ) { ?>
                                
                                    <div id="photos" class="media-grid">
                                           <?php for ( $i = 0; osc_has_item_resources() ; $i++ ) { ?>
                                           <a href="<?php echo osc_resource_url(); ?>" rel="image_group" title="<?php _e('Image', 'modern'); ?> <?php echo $i+1;?> / <?php echo osc_count_item_resources();?>">
                                               <?php if( $i == 0 ) { ?>
                                               <img src="<?php echo osc_resource_url(); ?>" width="310" alt="<?php echo osc_item_title(); ?>" title="<?php echo osc_item_title(); ?>"/>
                                               <?php } else { ?>
                                                   <img src="<?php echo osc_resource_thumbnail_url(); ?>" width="93" alt="<?php echo osc_item_title(); ?>" title="<?php echo osc_item_title(); ?>"/>
                                               <?php } ?>
                                           </a>
                                           <?php } ?>
                                       </div>
                                       <?php } ?>
					<!-- End Photos -->
									
					<!-- Item User Info -->
					<div id="contact" class="alert alert-normal item_contact" style="padding-left:10px;width:306px;">						
						<div class="modal-body" style="padding:10px;">
                                                  <span class="label grey" style="font-size:16px;padding:6px;float:right;text-transform: lowercase;">
                                                          <?php _e("Ref", 'twitter_bootstrap'); ?> <?php echo osc_item_id(); ?></span>
						 <div class="custom_fields">
							<?php if( osc_count_item_meta() > 0 ) { ?>
							<div class="meta_list">
								<?php //while ( osc_has_item_meta() ) { ?>
								<?php //if( osc_item_show_email() && osc_item_meta_value() != "" ) { ?>
                                                                <?php if( $m_phone != "" ) { ?>
								<p>
									<?php //echo osc_item_meta_name() ; ?> 
									<img alt="phone" width="13" src="<?php echo osc_current_web_theme_url('images/phone2.png') ; ?>" />
									<span style="font-size:22px;font-weight:bold;color:#404040;margin-left:6px;"><?php echo $m_phone;; ?></span>
								</p>
								
								<?php } ?>
							</div>
							<?php } ?>
						</div>
					     <?php if( osc_item_contact_name() != '' ) { ?>
                            <p class="name"><?php //_e('Name', 'modern') ?>
                                <h3><span style="font-weight:bold;">
                                    <?php echo osc_item_contact_name()?>
                                </span>
                                <span> - <?php echo user_type(); ?></span></h3>
                            </p>
                        <?php } ?>
                        <?php if( osc_item_show_email() and false) { ?>
                            <p class="email"><?php //_e('E-mail', 'modern'); ?><span style="font-weight:bold;"><a href="mailto:<?php echo osc_item_contact_email(); ?>"><?php echo osc_item_contact_email(); ?></a></span></p>
						<?php } ?>
                        <?php //if ( osc_user_phone() != '' ) { ?>
                            <!--<p class="phone"><?php //_e("Tel", 'modern'); ?>.:<span style="font-weight:bold;margin-left:10px;"> 
							<?php //echo osc_user_phone() ; ?></span></p>-->
                        <?php //} ?>						
						
                                              
						<p><?php seller_post(); ?></p>
						<?php //profile_picture_show(); ?>
						</div>
					</div>
					<!-- End Item User Info -->
					
				    <?php if ( !$is_expired && $is_user && $is_can_contact ) { ?>
					<!-- item contact -->
					<div id="item-contact" class="item_contact">
						<form class="well form-stacked" action="<?php echo osc_base_url(true) ; ?>" method="post" name="contact_form" id="contact_form" onsubmit="return doItemContact() ;" style="background-color:white;padding:0px;border: 1px solid #DDDDDD;margin-bottom:0px;">
							<input type="hidden" name="action" value="contact_post" />
							<input type="hidden" name="page" value="item" />
							<input type="hidden" name="id" value="<?php echo osc_item_id() ; ?>" />
							<div class="modal-header">								
								<h5><?php _e('Contact publisher', 'twitter_bootstrap') ; ?></h5>
							</div>
							<div class="modal-body">
								<?php osc_prepare_user_info() ; ?>   
                                                            
								<div class="clearfix">
									<label for="contact-yourName"><?php _e('Your name', 'twitter_bootstrap') ; ?></label>
									 <div class="input">
                                                                            <input class="xlarge contact-yourName" id="contact-yourName" name="yourName" type="text" value="<?php echo osc_logged_user_name(); ?>">                                                                            
                                                                         </div>
                                                                </div>
								<div class="clearfix">
									<label for="contact-yourEmail"><?php _e('Your e-mail', 'twitter_bootstrap') ; ?></label>
									<div class="input">
                                                                        <input class="xlarge contact-yourEmail" id="contact-yourEmail" name="yourEmail" type="text" value="<?php echo osc_logged_user_email();?>">
                                                                        </div>
								</div>
								<div class="clearfix">
									<label for="contact-phoneNumber"><?php _e('Phone number', 'twitter_bootstrap') ; ?></label>									
									<div class="input">
                                                                        <input class="xlarge contact-phoneNumber" id="contact-phoneNumber" name="phoneNumber" type="text" value="">
                                                                        </div>
								</div>
								<div class="clearfix">
									<label for="contact-message"><?php _e('Message', 'twitter_bootstrap') ; ?></label>									
									<div class="input">
                                                                        <textarea class="xlarge contact-message" id="contact-message" name="message" rows="6"></textarea>									
                                                                        </div>
                                                                </div>
								<?php /*
								<div class="clearfix">
									<?php osc_show_recaptcha(); ?>
								</div>
								*/ ?>
								<div class="clearfix" style="margin-right:2px;margin-bottom:0px;">
								<button class="btn primary" type="submit" style="float:right;width:100%;"><?php _e('Send', 'twitter_bootstrap') ; ?></button>
								</div>
							</div>
							<!--<div class="modal-footer">								
								<a class="btn item-contact-button-cancel" href="javascript://"><?php //_e('Cancel', 'twitter_bootstrap') ; ?></a>
							</div>-->
						</form>
					</div>
					<!-- item contact end -->
					<?php } ?>					
					
				</div>	
                </div>
                <!-- item detail end -->
                <?php if( $is_comments_enabled ) { ?>
                <!-- comments -->
                <div class="span16 columns comments well">
                    <?php if( $is_can_comment && (osc_item_total_comments() > 0) ) { ?>
                    <h2><?php _e('Comments', 'twitter_bootstrap'); ?></h2>
                    <!-- list comments -->
                    <div class="list-comments">
                        <?php while ( osc_has_item_comments() ) { ?>
                            <div class="comment">
                                <h3><?php echo osc_comment_title() ; ?> <small><em><?php _e("by", 'twitter_bootstrap') ; ?> <?php echo osc_comment_author_name() ; ?></small></em></h3>
                                <p><?php echo osc_comment_body() ; ?> </p>
                                <?php if ( osc_comment_user_id() && (osc_comment_user_id() == osc_logged_user_id()) ) { ?>
                                <p>
                                    <a rel="nofollow" href="<?php echo osc_delete_comment_url() ; ?>" title="<?php _e('Delete your comment', 'twitter_bootstrap') ; ?>"><?php _e('Delete', 'twitter_bootstrap') ; ?></a>
                                </p>
                                <?php } ?>
                            </div>
                        <?php } ?>
                        <?php if( ( !( osc_comments_per_page() == 0 ) || (osc_item_comments_page() === 'all') ) && ( osc_item_total_comments() >= osc_comments_per_page() ) ) { ?>
                        <div class="pagination">
                            <ul>
                                <?php echo twitter_comments_item_pagination() ; ?>
                            </ul>
                        </div>
                        <?php } ?>
                    </div>
                    <!-- list comments end -->
                    <?php } ?>
                    <!-- comment form -->
                    <form action="<?php echo osc_base_url(true); ?>" method="post" name="comment_form" onsubmit="return doComment();" >
                        <input type="hidden" name="action" value="add_comment" />
                        <input type="hidden" name="page" value="item" />
                        <input type="hidden" name="id" value="<?php echo osc_item_id() ; ?>" />
                        <fieldset>
                            <legend><?php _e('Leave your comment', 'twitter_bootstrap') ; ?></legend>
                            <div class="clearfix">
                                <label for="comment-authorName"><?php _e('Your name', 'twitter_bootstrap') ; ?></label>
                                <div class="input">
                                    <input class="xlarge comment-authorName" type="text" value="<?php echo osc_logged_user_name() ; ?>" name="authorName" id="comment-authorName">
                                </div>
                            </div>
                            <div class="clearfix">
                                <label for="comment-authorEmail"><?php _e('Your e-mail', 'twitter_bootstrap') ; ?></label>
                                <div class="input">
                                    <input class="xlarge comment-authorEmail" type="text" value="<?php echo osc_logged_user_email() ; ?>" name="authorEmail" id="comment-authorEmail">
                                </div>
                            </div>
                            <div class="clearfix">
                                <label for="comment-title"><?php _e('Title', 'twitter_bootstrap') ; ?></label>
                                <div class="input">
                                    <input class="xlarge comment-title" type="text" value="" name="title" id="comment-title">
                                </div>
                            </div>
                            <div class="clearfix">
                                <label for="comment-body"><?php _e('Comment', 'twitter_bootstrap') ; ?></label>
                                <div class="input">
                                    <textarea class="xlarge comment-body" id="comment-body" name="body" rows="6"></textarea>
                                </div>
                            </div>
                            <?php /*
                            <div class="clearfix">
                                <?php osc_show_recaptcha(); ?>
                            </div>
                            */ ?>
                            <div class="actions">
                                <button class="btn" type="submit"><?php _e('Post comment', 'twitter_bootstrap') ; ?></button>
                            </div>
                        </fieldset>
                    </form>
                    <!-- comment form end -->
                </div>
                <!-- comments end -->
                <?php } ?>
            </div>
        </div>

        <!-- item send friend -->
        <div id="item-sendfriend" class="modal hide fade item-sendfriend">
            <form class="form-stacked" action="<?php echo osc_base_url(true) ; ?>" method="post" name="sendfriend" onsubmit="return doItemSendFriend() ;">
                <input type="hidden" name="action" value="send_friend_post" />
                <input type="hidden" name="page" value="item" />
                <input type="hidden" name="id" value="<?php echo osc_item_id() ; ?>" />
                <div class="modal-header">
                    <a href="#" class="close">×</a>
                    <h3><?php _e('Send to a friend', 'twitter_bootstrap') ; ?></h3>
                </div>
                <div class="modal-body">
                    <div class="clearfix">
                        <label for="sendfriend-yourName"><?php _e('Your name', 'twitter_bootstrap') ; ?></label>
                        <div class="input">
                            <input class="xlarge sendfriend-yourName" id="sendfriend-yourName" name="yourName" type="text" value="">
                        </div>
                    </div>
                    <div class="clearfix">
                        <label for="sendfriend-friendName"><?php _e('Your e-mail', 'twitter_bootstrap') ; ?></label>
                        <div class="input">
                            <input class="xlarge sendfriend-yourEmail" id="sendfriend-yourEmail" name="yourEmail" type="text" value="">
                        </div>
                    </div>
                    <div class="clearfix">
                        <label for="sendfriend-friendName"><?php _e("Your friend's name", 'twitter_bootstrap') ; ?></label>
                        <div class="input">
                            <input class="xlarge sendfriend-friendName" id="sendfriend-friendName" name="friendName" type="text" value="">
                        </div>
                    </div>
                    <div class="clearfix">
                        <label for="sendfriend-friendEmail"><?php _e("Your friend's e-mail", 'twitter_bootstrap') ; ?></label>
                        <div class="input">
                            <input class="xlarge sendfriend-friendEmail" id="sendfriend-friendEmail" name="friendEmail" type="text" value="">
                        </div>
                    </div>
                    <div class="clearfix">
                        <label for="sendfriend-message"><?php _e('Message', 'twitter_bootstrap') ; ?></label>
                        <div class="input">
                            <textarea class="xlarge sendfriend-message" id="sendfriend-message" name="message" rows="6"></textarea>
                        </div>
                    </div>
                    <?php /*
                    <div class="clearfix">
                        <?php osc_show_recaptcha(); ?>
                    </div>
                    */ ?>
                </div>
                <div class="modal-footer">
                    <button class="btn primary" type="submit"><?php _e('Send', 'twitter_bootstrap') ; ?></button>
                    <a class="btn item-sendfriend-button-cancel" href="javascript://"><?php _e('Cancel', 'twitter_bootstrap') ; ?></a>
				
                </div>	
            </form>
        </div>
        <!-- item send friend end -->
        <script type="text/javascript">
            var text_error_required = '' ;
            var text_valid_email    = '' ;
        </script>
        <script type="text/javascript" src="<?php echo osc_current_web_theme_js_url('item_contact.js') ; ?>"></script>
        <script type="text/javascript" src="<?php echo osc_current_web_theme_js_url('item_sendfriend.js') ; ?>"></script>
        <script type="text/javascript" src="<?php echo osc_current_web_theme_js_url('item_comment.js') ; ?>"></script>
        <?php osc_current_web_theme_path('footer.php') ; ?>
    </body>
</html>